package com.google.code.flexmetavalidator.reflection
{
	import flash.utils.Dictionary;

	public class MetaTag
	{
		public static function fromXmlDescriptor(desc : XML) : MetaTag
		{
			var retTag : MetaTag = new MetaTag();
			retTag.name = String(desc.@name);
			retTag.metaParameters = new Array();
			var xArgs : XMLList = desc.arg;
			for each (var arg : XML in xArgs)
			{
				 retTag.metaParameters.push(new MetaParameter(arg.@key, arg.@value));
			}
			
			return retTag;
		}
		
		public var name : String;
		public var metaParameters : Array;
		
		public function get metaParametersDictionary() : Dictionary
		{
			var retDictionary : Dictionary = new Dictionary();
			for each (var metaParameter : MetaParameter in metaParameters)
			{
				retDictionary[metaParameter.name] = metaParameter;
			}
			return retDictionary;
		}
		
		public function MetaTag(name : String = null, metaParameters : Array = null)
		{
			this.name = name;
			this.metaParameters = metaParameters;
		}
	}
}